//输入框input失去焦点时检测输入内容是否合法
(function(){
  var pass,confirm,phone;
  if ($('#password')[0]){
    pass = $('#password');
    pass.on('blur',function(e){
      var targetSpan = $(e.target).parent().find('span');
      var passVal = e.target.value;
      if (!passVal){
        targetSpan.html('密码不能为空');
      }else{
        targetSpan.html('');
      }
    })
  }
  if($('#confirm')[0]){
    confirm = $('#confirm');
    confirm.on('blur',function(e){
      var targetSpan = $(e.target).parent().find('span');
      var passVal = $('#password').val();
      var conPass = $('#confirm').val();
      if (passVal === conPass){
        targetSpan.html('');
      }else{
        targetSpan.html('两次输入密码不一致');
      }
    });
  }
  if($('#phone')[0]){
    phone = $('#phone');
    phone.on('blur',function(e){
      var targetSpan = $(e.target).parent().find('span');
      var phoneReg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
      console.log('qweras');
      var phoneNum = $(e.target).val();
      console.log(phoneNum);
      console.log(phoneReg.test(phoneNum));
      if(!phoneNum){
        targetSpan.html('手机号不为空');
      }else if(phoneReg.test(phoneNum)){
        targetSpan.html('');
      }else{
        targetSpan.html('手机号不合法');
      }
    })
  }


  smallSide();
})();